import request from '../http/request'
import type { ApiResponse, SubjectProgress } from '../http/types'

export interface ProgressData {
  subjects: Partial<SubjectProgress>
  settings?: {
    theme?: 'light' | 'dark'
    difficulty?: 'easy' | 'medium' | 'hard'
    notifications?: boolean
  }
}

export const progressApi = {
  // 获取用户学习进度
  getUserProgress: (userId: string): Promise<ApiResponse<ProgressData>> => {
    return request.get(`/progress/${userId}`)
  },

  // 保存用户学习进度
  saveUserProgress: (userId: string, data: ProgressData): Promise<ApiResponse> => {
    return request.post(`/progress/${userId}`, data)
  },

  // 更新特定科目进度
  updateSubjectProgress: (userId: string, subject: string, progress: any): Promise<ApiResponse> => {
    return request.patch(`/progress/${userId}/subjects/${subject}`, progress)
  },
}
